package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"month2/C/api_C/internal/config"
	"month2/C/api_C/internal/middleware"
	"month2/C/rpc_C/order"
	"month2/C/rpc_C/orderclient"
)

type ServiceContext struct {
	Config    config.Config
	AuthToken rest.Middleware
	CRpc      order.OrderClient
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:    c,
		AuthToken: middleware.NewAuthTokenMiddleware().Handle,
		CRpc:      orderclient.NewOrder(zrpc.MustNewClient(c.CRpc)),
	}
}
